package com.chinairi.mall.controller;


import com.chinairi.common.utils.ResponseUtil;
import com.chinairi.mall.service.modelobject.OCTAForSPMO;
import com.chinairi.mall.controller.viewobject.OCTIForSPVO;
import com.chinairi.mall.controller.viewobject.OCTListVO;
import com.chinairi.mall.service.IOrderCommodityTrackService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.chinairi.common.controller.BaseController;

import java.io.IOException;
import java.util.List;

/**
 * <p>
 * 服务单号商品绑定追踪节点表 前端控制器
 * </p>
 *
 * @author Webgasd
 * @since 2020-08-30
 */
@RestController
@RequestMapping("/order-commodity-track")
public class OrderCommodityTrackController extends BaseController {

    private static final long serialVersionUID = -462559027517157163L;

    @Autowired
    private IOrderCommodityTrackService iOrderCommodityTrackService;

    @PostMapping("/config")
    @ResponseBody
    public void config(@RequestBody OCTListVO octListVO) throws IOException {
        iOrderCommodityTrackService.config(octListVO.getServiceIdList());
        ResponseUtil.showMessage("success", "配置成功", null);
    }

    /**
     * 向服务供应商传出所有订单的所有商品的所有节点信息。
     * @param octaForSPMO
     * @throws IOException
     */
    @GetMapping("/postAlarmForServiceProvider")
    @ResponseBody
    public void postAlarmForServiceProvider(OCTAForSPMO octaForSPMO) throws IOException {
        List<OCTAForSPMO> list = iOrderCommodityTrackService.getAlarmList(octaForSPMO);
        ResponseUtil.showMessage("success", "请求成功", list);
    }

    /**
     * 向服务提供商传输所有订单下的商品的所有报警需求信息
     * @param octiForSPVO
     * @throws IOException
     */
    @GetMapping("/postInformationForServiceProvider")
    @ResponseBody
    public void postInformationForServiceProvider(OCTIForSPVO octiForSPVO) throws IOException {
        List<OCTIForSPVO> list = iOrderCommodityTrackService.getInformationList(octiForSPVO);
        ResponseUtil.showMessage("success", "请求成功", list);
    }
}
